Skip to content

Fix case-insensitive extension lookup in CygwinCCompiler._make_out_path#5223

Open
armorbreak001 wants to merge 1 commit intopypa:mainfrom
armorbreak001:fix-cygwin-normcase-extension-casing
Open

Fix case-insensitive extension lookup in CygwinCCompiler._make_out_path#5223
armorbreak001 wants to merge 1 commit intopypa:mainfrom
armorbreak001:fix-cygwin-normcase-extension-casing

Conversation

@armorbreak001
Copy link
Copy Markdown

Summary

os.path.normcase was applied to the source filename but not to the
extension lookup keys in out_extensions. On Cygwin/Windows, normcase
lowercases the filename, so a source file like foo.S would have its
suffix lowercased to .s. If .s was not a key in out_extensions
(e.g. only .S was added via src_extensions.append(".S")), this
raised UnknownFileType: unknown file type '.s'.

Fix

Apply os.path.normcase to both the source name and the extension
dictionary keys so that any casing of .rc, .S, .c, etc. is handled
correctly regardless of how the extension was registered.

This preserves the original intent of the normcase call (handling
.RC.rc for resource files) while also fixing uppercase extensions
like .S for assembly files.

Closes #5130

os.path.normcase was applied to the source filename but not to the
extension lookup keys in out_extensions. This caused uppercase
extensions like '.S' (assembly) to fail with an 'unknown file type'
error when added to src_extensions, since normcase lowercased the
suffix to '.s' which had no matching key.

Apply normcase to both the source name and the extension keys so
that any casing of '.rc', '.S', etc. is handled correctly.

Closes pypa#5130
@abravalheri
Copy link
Copy Markdown
Contributor

Hi @armorbreak001 , thank you for the contribution.

Usually changes in the _distutils folder are analysed first in the context of the pypa/distutils project.

Setuptools simply merge the upstream repo back into the _distutils folder. If we change that directory directly, chances are the next update may overwrite all the changes (that is why we avoid changing it directly here).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] cygwin C compiler fails to respect source file extension casing

2 participants